package com.atguigu.date;
import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class DatePractice2 {
    @Test
    //从1990-01-01开始进行三天打鱼，两天晒网
    public static void main(String[] args) {


        System.out.println("请输入日期:");
        Scanner scan = new Scanner(System.in);
        String nowDate = scan.next();
        Date date1 =null;
        Date date2=null;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String str1 = "1990-01-01";
        try {
            date1 = simpleDateFormat.parse(str1);
            date2 = simpleDateFormat.parse(nowDate);
        }catch(ParseException e){
            e.printStackTrace();
        long data = date2.getTime() - date1.getTime();
        int day=Math.round(data/31536000000l);
            System.out.println(day
            );
    }
}
}
